package name.cyrax.red.jpv.impl.adapters;

import java.util.Arrays;

public enum NumericType {
	INTEGER(int.class, Integer.class) {
		@Override public void fillArray(Object array, Number value)
		{
			Arrays.fill((int[]) array, value.intValue());
		}

		@Override public boolean isZero(Number value)
		{
			return value.intValue() == 0;
		}
	},
	LONG(long.class, Long.class) {
		@Override public void fillArray(Object array, Number value)
		{
			Arrays.fill((long[]) array, value.longValue());
		}

		@Override public boolean isZero(Number value)
		{
			return value.longValue() == 0;
		}
	},
	DOUBLE(double.class, Double.class) {
		@Override public void fillArray(Object array, Number value)
		{
			Arrays.fill((double[]) array, value.doubleValue());
		}

		@Override public boolean isZero(Number value)
		{
			return value.doubleValue() == 0.0D;
		}
	};
	
	private final Class<?> primType;
	private final Class<? extends Number> boxType;
	
	private NumericType(Class<?> primType, Class<? extends Number> boxType)
	{
		this.primType = primType;
		this.boxType = boxType;
	}

	public Class<?> getPrimType()
	{
		return primType;
	}

	public Class<? extends Number> getBoxType()
	{
		return boxType;
	}
	
	public abstract void fillArray(Object array, Number value);
	public abstract boolean isZero(Number value);
}